package com.team1.supervend.state_machine;

public class SuperVend {
 
	State idleState;
	State processingSaleState;
	State acceptingPaymentMethodState;
	State acceptingMoneyForPaymentState;
	State acceptingCreditCardForPaymentState;
	State acceptingCustomerOrderState;
	State vendingPurchasedProductsState;
 
	State state;
 
	public SuperVend() {
		idleState = new IdleState(this);
		processingSaleState = new ProcessingSaleState(this);
		acceptingPaymentMethodState = new AcceptingPaymentMethodState(this);
		acceptingMoneyForPaymentState = new AcceptingMoneyForPaymentState(this);
		acceptingCreditCardForPaymentState = new AcceptingCreditCardForPaymentState(this);
		acceptingCustomerOrderState = new AcceptingCustomerOrderState(this);
		vendingPurchasedProductsState = new VendingPurchasedProductsState(this);
		
		state = idleState;
	}
 

	public void startSale() {
		state.startSale();
	}

	public void cancelSale() {
		state.cancelSale();
	}

	public void endSale() {
		state.endSale();
	}

	public void returnToIdle() {
		state.returnToIdle();
	}

	public void preValidatePayment() {
		state.preValidatePayment();
	}

	public void payBalance() {
		state.payBalance();
	}

	public void cancelPayment() {
		state.cancelPayment();
	}

	public void chooseCashPayment() {
		state.chooseCashPayment();
	}

	public void insertMoney(float denomination) {
		state.insertMoney(denomination);
	}

	public void makeCashPayment() {
		state.makeCashPayment();
	}

	public void supplyCreditCardInformation() {
		state.supplyCreditCardInformation();
	}

	public void paymentAuthorized() {
		state.paymentAuthorized();
	}

	public void allowProductSelection() {
		state.allowProductSelection();
	}

	public void chooseProduct(int quantity) {
		state.chooseProduct(quantity);
	}

	public void productSelectionComplete() {
		state.productSelectionComplete();
	}

	void setState(State state) {
		this.state = state;
	}
 
    public State getState() {
        return state;
    }
    
    public State getAcceptingCreditCardForPaymentState() {
        return acceptingCreditCardForPaymentState;
    }

    public State getAcceptingCustomerOrderState() {
        return acceptingCustomerOrderState;
    }

    public State getAcceptingMoneyForPaymentState() {
        return acceptingMoneyForPaymentState;
    }

    public State getAcceptingPaymentMethodState() {
        return acceptingPaymentMethodState;
    }

    public State getIdleState() {
        return idleState;
    }

    public State getProcessingSaleState() {
        return processingSaleState;
    }

    public State getVendingPurchasedProductsState() {
        return vendingPurchasedProductsState;
    }

    public String toString() {
		StringBuffer result = new StringBuffer();
		result.append("                            " + state );
		return result.toString();
	}
}
